package com.example.hangzhou.welbeing.mytestdemoapp.mvp.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.TextView;

import com.example.hangzhou.welbeing.mytestdemoapp.R;
import com.example.hangzhou.welbeing.mytestdemoapp.mvp.adpter.NumberAdapter;
import com.example.hangzhou.welbeing.mytestdemoapp.utils.GlideImageLoader;
import com.youth.banner.Banner;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 杭州惟君医疗科技有限公司15
 * Created by 20433 on 2018/5/11
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class MyMainActivity extends AppCompatActivity  {


    @Bind(R.id.activity_my_main_tv_title)
    TextView activityMyMainTvTitle;
    @Bind(R.id.activity_my_main_toolbar)
    Toolbar activityMyMainToolbar;
    @Bind(R.id.activity_my_main_tb_slidings)
    TabLayout activityMyMainTbSlidings;
    @Bind(R.id.app_bar_main_appbar)
    AppBarLayout appBarMainAppbar;
    @Bind(R.id.activity_my_main_viewpager)
    ViewPager activityMyMainViewpager;
    @Bind(R.id.activity_my_main_fab)
    FloatingActionButton activityMyMainFab;
    @Bind(R.id.nav_view)
    NavigationView navView;
    @Bind(R.id.drawer_layout)
    DrawerLayout drawerLayout;
    @Bind(R.id.activity_my_main_banner)
    Banner activityMyMainBanner;
    @Bind(R.id.activity_my_main_collapsingToolbarLayout)
    CollapsingToolbarLayout activityMyMainCollapsingToolbarLayout;
    List<Integer> images = new ArrayList<>();
    private ActionBarDrawerToggle mDrawerToggle;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_main);
        ButterKnife.bind(this);
        tobarAndDrawerlayout();
        images.add(R.mipmap.placeholder_mom);
        images.add(R.drawable.planet_two);
        images.add(R.mipmap.placeholder_mom);
        images.add(R.drawable.planet_five);
        activityMyMainCollapsingToolbarLayout.setTitle("");
        NumberAdapter numberAdapter =    new NumberAdapter(getSupportFragmentManager());
        activityMyMainViewpager.setAdapter(numberAdapter);
      activityMyMainTbSlidings.setupWithViewPager(activityMyMainViewpager);
        activityMyMainTbSlidings.setTabMode(TabLayout.MODE_FIXED);
        activityMyMainBanner.setImages(images).setImageLoader(new GlideImageLoader()).start();//这里接收集合,上面写成集合太占地方，这个大家举一反三就行了啊
    }

    private void tobarAndDrawerlayout() {
        setSupportActionBar(activityMyMainToolbar);
        activityMyMainToolbar.setNavigationIcon(R.drawable.menu);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        //创建返回键，并实现打开关/闭监听
        mDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, 0, 0);
        mDrawerToggle.syncState();
        drawerLayout.setDrawerListener(mDrawerToggle);
        //让图片就是显示他本身的颜色
        navView.setItemIconTintList(null);


    }


    @OnClick(R.id.activity_my_main_fab)
    public void onViewClicked() {

    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        if (item.getItemId() == android.R.id.home) {
            mDrawerToggle.onOptionsItemSelected(item);
            return true;
        }

        return super.onOptionsItemSelected(item);
    }


}
